Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clean-deep

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clean-deep

Remove falsy, empty or nullable values from objects

  • 3.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
121K
decreased by-55.59%
Maintainers
3
Weekly downloads
 
Created

What is clean-deep?

The clean-deep npm package is used to deeply clean JavaScript objects by removing properties with specific values such as null, undefined, empty strings, empty arrays, and empty objects. This is useful for sanitizing data before processing or sending it over a network.

What are clean-deep's main functionalities?

Remove null and undefined values

This feature removes properties with null and undefined values from the object.

const cleanDeep = require('clean-deep');
const obj = { a: null, b: undefined, c: 'value' };
const cleanedObj = cleanDeep(obj);
console.log(cleanedObj); // Output: { c: 'value' }

Remove empty strings

This feature removes properties with empty string values from the object.

const cleanDeep = require('clean-deep');
const obj = { a: '', b: 'value' };
const cleanedObj = cleanDeep(obj);
console.log(cleanedObj); // Output: { b: 'value' }

Remove empty arrays

This feature removes properties with empty array values from the object.

const cleanDeep = require('clean-deep');
const obj = { a: [], b: [1, 2, 3] };
const cleanedObj = cleanDeep(obj);
console.log(cleanedObj); // Output: { b: [1, 2, 3] }

Remove empty objects

This feature removes properties with empty object values from the object.

const cleanDeep = require('clean-deep');
const obj = { a: {}, b: { c: 'value' } };
const cleanedObj = cleanDeep(obj);
console.log(cleanedObj); // Output: { b: { c: 'value' } }

Custom values to remove

This feature allows you to specify custom values to be removed from the object.

const cleanDeep = require('clean-deep');
const obj = { a: 'remove me', b: 'keep me' };
const cleanedObj = cleanDeep(obj, { cleanValues: ['remove me'] });
console.log(cleanedObj); // Output: { b: 'keep me' }

Other packages similar to clean-deep

Keywords

FAQs

Package last updated on 19 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc